<%@ taglib prefix="spring-tags" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="spring-form" uri="http://www.springframework.org/tags/form"%>
<%@ page
    import="org.jiscinvolve.astrodabis.barberry.control.Paths"
    import="org.jiscinvolve.astrodabis.barberry.control.ObjectData"
    import="org.jiscinvolve.astrodabis.barberry.control.RequestData"
    import="org.jiscinvolve.astrodabis.barberry.common.core.Tag"
    import="org.jiscinvolve.astrodabis.barberry.common.core.Account"
    import="org.jiscinvolve.astrodabis.barberry.common.data.TapService"
    import="org.jiscinvolve.astrodabis.barberry.common.data.TapTable"
    import="org.jiscinvolve.astrodabis.barberry.common.data.TapColumn"
    import="org.jiscinvolve.astrodabis.barberry.common.data.TapJoin"
    import="org.jiscinvolve.astrodabis.barberry.common.data.TapRow"
    import="org.jiscinvolve.astrodabis.barberry.common.data.JoinTag"
    session="true"
%><%
ObjectData<TapJoin> data = (ObjectData<TapJoin>) request.getAttribute(
    RequestData.MODEL_ATTRIB
    ) ;
Account actor = data.actor();
TapJoin join = data.object();
%>
<html>
    <head>
	    <title>AstroDAbis TAP join <%= join.ident() %></title>
        <link href='<%= data.file("css/page.css") %>' rel='stylesheet' type='text/css'/>
    </head>
    <body>
        <%@ include file="/jsp/header.jsp" %>
        <div class='body'>
            <div class='left'>
                <%@ include file="/jsp/menu.jsp" %>
            </div>
            <div class='right'>
                <a href='<%= data.link(join) %>'>
                    <img src='<%= data.qrcode(data.link(join)) %>'/>
                </a>
            </div>
            <div class='content'>
        	    <h2>TAP join <%= join.ident() %></h2>
                <fieldset>
                    <legend>Primary row</legend>
                    <div>
                        <ul>
                            <li>
                                Service : <a href='<%= data.link(join.one().parent().parent().parent()) %>'><%= join.one().parent().parent().parent().name() %></a>
                            </li>
                            <li>
                                Table : <a href='<%= data.link(join.one().parent().parent()) %>'><%= join.one().parent().parent().name() %></a>
                            </li>
                            <li>
                                Column : <a href='<%= data.link(join.one().parent()) %>'><%= join.one().parent().name() %></a>
                            </li>
                            <li>
                                Row  : <a href='<%= data.link(join.one()) %>'><%= join.one().value() %></a>
                            </li>
                        </ul>
                    </div>
                </fieldset>

                <fieldset>
                    <legend>Associated row</legend>
                    <div>
                        <ul>
                            <li>
                                Service : <a href='<%= data.link(join.two().parent().parent().parent()) %>'><%= join.two().parent().parent().parent().name() %></a>
                            </li>
                            <li>
                                Table : <a href='<%= data.link(join.two().parent().parent()) %>'><%= join.two().parent().parent().name() %></a>
                            </li>
                            <li>
                                Column : <a href='<%= data.link(join.two().parent()) %>'><%= join.two().parent().name() %></a>
                            </li>
                            <li>
                                Row  : <a href='<%= data.link(join.two()) %>'><%= join.two().value() %></a>
                            </li>
                        </ul>
                    </div>
                </fieldset>

                <fieldset>
                    <legend>Join tags</legend>
                    <table>
                        <thead>
                            <tr>
                                <td>join-tag</td>
                                <td>owner</td>
                                <td>name</td>
                                <td>value</td>
                            </tr>
                        </thead>
                        <tbody>
                            <%
                            for (JoinTag jointag : join.tags().select())
                                {
                                %>
                                <tr>
                                    <td>
                                        <a href="<%= data.link(jointag) %>"><%= jointag.ident() %></a>
                                    </td>
                                    <td>
                                        <a href="<%= data.link(jointag.tag().owner()) %>"><%= jointag.tag().owner().name() %></a>
                                    </td>
                                    <td>
                                        <a href="<%= data.link(jointag.tag()) %>"><%= jointag.tag().name() %></a>
                                    </td>
                                    <td>
                                        <%= (jointag.value() != null) ? jointag.value() : "&nbsp;" %>
                                    </td>
                                </tr>
                                <%
                                }
                            %>
                        </tbody>
                    </table>
                </fieldset>

            </div>
        </div>
        <%@ include file="/jsp/footer.jsp" %>
    </body>
</html>

